package hot.job.core.factory;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;


/**
 * autowire capable job factory
 *
 * @author gaowenhao
 * @since 2022/7/5 10:38
 */
public class AutowireCapableJobFactory extends SpringBeanJobFactory {

    private final AutowireCapableBeanFactory autowireCapableBeanFactory;


    public AutowireCapableJobFactory(AutowireCapableBeanFactory autowireCapableBeanFactory) {
        this.autowireCapableBeanFactory = autowireCapableBeanFactory;
    }


    @NonNull
    @Override
    protected Object createJobInstance(@NonNull TriggerFiredBundle bundle) throws Exception {
        Object jobInstance = super.createJobInstance(bundle);
        this.autowireCapableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }


    private String generateBeanName(){
        return null;
    }

}
